import { Component, Input, ViewChild } from '@angular/core';

@Component({
  selector: 'app-add-model',
  templateUrl: './add-model.component.html'
})
export class AddModelComponent {
  isVisible = false;

  nzTitle = "新增用户";

  addButtonName = "确认添加"

  @ViewChild('form') form: any;

  showModal(e: MouseEvent, buttonName: string): void {
    this.setButtonName(buttonName);
    if (this.form.buttonName == "确认添加") {
      this.form.validateForm.reset();
      this.form.radio.setRadioValue("激活");
      this.nzTitle = "新增用户";
    }
    this.isVisible = true;
  }

  handleCancel(): void {
    this.isVisible = false;
  }

  upateNzTitle() {
    this.nzTitle = "修改用户";
  }

  setEditingUser(id: string) {
    this.form.setEditingUser(id);
  }

  //设置确认按钮名字
  setButtonName(buttonName: string) {
    this.form.buttonName = buttonName;
  }

}